package com.superman.supermarket.client.widget.button;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.superman.mvpframe.client.gin.XGinjector;
import com.superman.supermarket.client.gin.ShopGinjector;

/**
 * 回到首页按钮
 * 
 * @author superman
 * @version 2018年8月2日下午9:43:54
 */
public class HomeButton extends HTML {

	/**
	 * 构造方法
	 * 
	 * @author superman
	 * @version 2018年8月2日 下午9:45:55
	 */
	public HomeButton() {
		this.getElement().getStyle().setProperty("backgroundImage",
				"url(\"\")");
		this.getElement().getStyle().setProperty("width", "0.586667rem");
		this.getElement().getStyle().setProperty("height", "0.586667rem");
		this.getElement().getStyle().setProperty("backgroundSize", "0.586667rem 0.586667rem");
		this.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {

				// if (StringUtils.isEmpty(getState()) || URLHashAndPlaceMapper.isEmpty())
				// {
				XGinjector.INSTANCE.getMyPlaceController().push(ShopGinjector.INSTANCE.getMyPlaceFactory().getHomePlace());
				// } else {
				// XGinjector.INSTANCE.getMyPlaceController().backHome();
				// }

			}
		});
	}

	private native String getState()/*-{
									return $wnd.history.state;
									}-*/;

}
